<template>
  <!-- <dv-border-box-10 :color="['#50649a', '#50649b']"> -->
  <div class="award">
    <table>
      <thead>
        <tr>
          <th>序号</th>
          <th>获奖项</th>
          <th>获奖类型</th>
        </tr>
      </thead>
      <tbody ref="awardsList">
        <tr v-for="(award, index) in sortedAwards" :key="index">
          <td>{{ index + 1 }}</td>
          <td>{{ award.name }}</td>
          <td>{{ award.stuStates }}</td>
        </tr>
      </tbody>
    </table>
  </div>
  <!-- </dv-border-box-10 > -->
</template>

<script>
import pubsub from "pubsub-js";
export default {
  name: "GetAward",
  data() {
    return {
      awards: [
        {
          id: 5,
          stuId: "2020105437644",
          name: "全国大学生机械创新设计大赛 国三",
          amount: 1000,
          stuStates: "国家A类竞赛",
        },
      ],
      stuId: "",
    };
  },
  methods: {
    getInfo() {
      this.$http({
        url: this.$http.adornUrl(`/chaoxing/awardstatus/info/${this.stuId}`),
        method: "get",
      }).then((response) => {
        this.awards = response.data.data;
      });
    },
  },
  computed: {
    sortedAwards() {
      return this.awards.slice().sort((a, b) => {
        return parseInt(b.amount) - parseInt(a.amount);
      });
    },
  },
  mounted() {
    this.pubId = pubsub.subscribe("selectStuInfo", (msgName, data) => {
      this.stuId = data;
      // console.log("获得奖项", this.stuId);
      this.getInfo();
    });
  },
};
</script>

<style scoped>
.arward {
  width: 100%;
  height: 100%;
  padding: 5px;
  background-color: aquamarine;
}
table {
  height: 100%;
  width: 500px;
  border-collapse: collapse;
}
th {
  /* height: 30px; */
  padding: 5px 0;
}
th,
td {
  font-size: 16px;
  height: 20px;
  border: 1px solid #00FFFF;
  text-align: center;
}
th:nth-child(1),
td:nth-child(1) {
  width: 20px;
}
th:nth-child(3),
td:nth-child(3) {
  width: 30px;
}
th {
  background-color: #00ffff61;
}
@media only screen and (max-width: 600px) {
  table,
  th,
  td {
    display: block;
  }
  th,
  td {
    border: none;
    text-align: left;
  }
}
</style>
